<?php session_start(); ob_start();
include "conexao.php";


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html;charset=iso-8859-1" />

<title></title>

<style type="text/css">
#table3 
	{
	visibility: visible;
	width: 100px;
	
	position: relative
	}
#table3 table   
	{
	font-size: 10px;
	font-family: Verdana, Geneva, Arial, sans-serif;
	background-color: transparent
	
	}
#table3 td
	{
	background-color: #F7F7F7;
	padding: 0px 4px 0px 4px;
	border-width: 1px 1px 1px 1px;
	border-style: solid;
	border-color: #ffffff #C5CCC5 #C5CCC5 #ffffff
	
	}
#table3 th
	{
	padding: 0px 2px 0px 2px;
	border-width: 2px 2px 2px 2px;
	border-style: solid;
	border-color: #ffffff #C5CCC5 #C5CCC5 #ffffff;
	background-color: #d5ddd5;
	text-align: left;
	
	}
	

</style>

</head>

<body>



 
	  
		
            <p><div style="display:block" id="busc_prod">
<div id="apDiv1">
<div id="pagina"></div>
</div></div>
            <div id="table3">	  <table width="12%" border="0" cellspacing="0" cellpadding="4">
      <tr>
        <?php
		$sql = "SELECT * FROM categoria_servicos";
		// WHERE id_categoria IN (SELECT id_categoria FROM anuncios WHERE ativo = 'S')
		$qry = mysql_query($sql);
		while ($linha = mysql_fetch_array($qry))
		{  $id_cat = $linha['id_categoria']; ?>
       <td width="150" align ="center" valign="top"><table width="43%" border="0" cellspacing="0" cellpadding="0" height="115" >
            <tr>
              <td valign="top"><div class="bordaBoxCat">
<b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b>
<div class="conteudo  style8"><?php echo "<b><div class=uppercasecat>".$linha['categoria']."</div></b>"; ?></div>
<b class="b4"></b><b class="b3s></b><b class="bs2"></b><b class="b1s"></b>
</div>
				  <?php 
		  $sql_sub = "SELECT * FROM subcategoria_servicos where id_categoria = '$id_cat'";
		  // and id_subcategoria IN (SELECT id_subcategoria FROM anuncios WHERE ativo = 'S')
		$qry_sub = mysql_query($sql_sub);
		$io=0;
		while ($linha_sub = mysql_fetch_array($qry_sub))
		{
		 $id_subcategoria = $linha_sub['id_subcategoria'];
		 $sql_qtdeprod = mysql_query ("SELECT a.id_anuncios_categoria, s.id_subcategoria FROM anuncios_categoria a, subcategoria_servicos s WHERE a.id_subcategoria = s.id_subcategoria and a.id_subcategoria = '$id_subcategoria' and a.ativo = 'S'");
		$qtde_produtos = mysql_num_rows($sql_qtdeprod);  
		
		  
		   echo "<a href=classificados2.php?id_cat=$linha_sub[id_categoria]&id_subcat=$linha_sub[id_subcategoria]&qtde=$qtde_produtos> <div class=stylelinkmenu>&nbsp;$linha_sub[subcategoria] [$qtde_produtos]</div></a><br>------------------";    
	
		}?><br></td>
            </tr>
       </table></td>
        <?php 
		++$i;
		if ($i%2==0)
		  echo "</tr>";
		   } ?>
      </tr>
    </table></div></p>
		  </div>
      </div>
</div>
       <div id="propag" style="display:block">
		<div id="direita">
		  
	
        
		<div style="clear: both;"></div>
	

	<div id="rodape">
		<div id="rodape_direita"></div>
  

</body>
</html>
<?php 
if(!isset($_COOKIE["cookiecontagem_classificados"]) && $_SESSION["txt_login"]==""){
$dat = date("Y/m/d");
$dias   = date("d");
$mess = date("m");
$anoo  = date("Y");

$verifica = mysql_query("SELECT data FROM visitas WHERE data = '$dat'");
if(mysql_num_rows($verifica)==""){
mysql_query("INSERT INTO visitas (data, visitas_classificados) values ('$dat','1')");
}else{
mysql_query("UPDATE visitas SET visitas_classificados = visitas_classificados + '1' WHERE data = '$dat'");
}

setcookie("cookiecontagem_classificados","true", mktime(23, 59, 30, $mess, $dias, $anoo));
}
ob_end_flush();
?>
